package jp.reflexworks.atom.util;

import java.util.List;

import javax.jdo.PersistenceManager;
import javax.jdo.Query;

import jp.reflexworks.atom.entry.Entry;
import jp.reflexworks.atom.feed.Feed;



public class JdoUtils {

	public static void insert(Feed feed) {
		PersistenceManager pm = PMF.get().getPersistenceManager();
		pm.makePersistent(feed);
	}

	public static void insert(Entry atom) {
		PersistenceManager pm = PMF.get().getPersistenceManager();
		pm.makePersistent(atom);
	}

	public static List<Entry> getEntries() {
		PersistenceManager pm = PMF.get().getPersistenceManager();
		Query query = pm.newQuery(Entry.class);

		List<Entry> feeds = (List<Entry>) query.execute();
		return feeds;
	}

	public static List<Feed> getFeeds() {
		PersistenceManager pm = PMF.get().getPersistenceManager();
		Query query = pm.newQuery(Feed.class);

		List<Feed> feeds = (List<Feed>) query.execute();
		return feeds;
	}

}
